package cn.wolfcode.luowowo.website.controller;

import cn.wolfcode.luowowo.acticle.domain.Planeticket;
import cn.wolfcode.luowowo.acticle.query.PlaneticketQuery;
import cn.wolfcode.luowowo.acticle.service.IPlaneticketService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 机票
 */
@Controller
@RequestMapping("/planeticket")
public class PlaneticketController {

    @Reference
    private IPlaneticketService planeticketService;

    /**
     * 机票首页
     * @return
     */
    @RequestMapping("")
    public String index(){
        return "planeticket/index";
    }

    /**
     * 航班信息显示
     * @param m
     * @param qo
     * @return
     */
    @RequestMapping("/list")
    public String list(Model m, @ModelAttribute("qo") PlaneticketQuery qo){
        PageInfo pageInfo = planeticketService.query(qo);
        m.addAttribute("pageInfo",pageInfo);
        return "planeticket/list";
    }

    @RequestMapping("/order")
    public String order(Model m,Long id){
        Planeticket planeticket = planeticketService.getParameterById(id);
//        planeticket.setWeekday(dateToWeekday(planeticket.getStartdate()));
        m.addAttribute("planeticket",planeticket);
        return "planeticket/order1";
    }


}
